package com.zmx.common.common.config.shardingsphere;

import com.zmx.common.common.utils.id.Id;
import com.zmx.common.common.utils.id.Id0ddEven;
import org.apache.shardingsphere.spi.keygen.ShardingKeyGenerator;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Properties;

/**
 * @Description: shardingsphere 自定义分布式主键生成器
 * @ClassName: MyKeyGenerator
 * @Author zhaomxr
 * @Date 2021-12-09 14:42
 */
public class MyKeyGenerator implements ShardingKeyGenerator {

    @Autowired
    private Id0ddEven id0ddEven;

    @Override
    public Comparable<?> generateKey() {
        return id0ddEven.generateId0ddEven();
    }

    @Override
    public String getType() {
        return "MyKeyGenerator";
    }

    @Override
    public Properties getProperties() {
        return null;
    }

    @Override
    public void setProperties(Properties properties) {

    }
}
